#include "LJZDLL.h"
#include <vector>
#include <mutex>

namespace LJZDLL
{
	extern "C"
	{
		LJZAPI unsigned long LXS50EVKeyL1SeedToKey(unsigned int num_rounds, unsigned long seed)
		{
			unsigned long seedTemp1 = seed, seedTemp2 = ~seed;
			unsigned long sum = 0, delta = 0x0AB13008;
			unsigned long k[4];
			k[0] = 0x4c495551;
			k[1] = 0x49534545;
			k[2] = 0x444b4559;
			k[3] = 0x414c474f;
			for (unsigned long i = 0; i < num_rounds; i++)
			{
				seedTemp1 += (((seedTemp2 << 4) ^ (seedTemp2 >> 5)) + seedTemp2) ^ (sum + k[sum & 3]);
				sum += delta;
				seedTemp2 += (((seedTemp1 << 4) ^ (seedTemp1 >> 5)) + seedTemp1) ^ (sum + k[(sum >> 11) & 3]);
			}

			return seedTemp1;
		}
	}
}